package crivia.ecp.ebp;

import java.io.PrintWriter;
import java.net.URLEncoder;
import java.util.Enumeration;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;

import crivia.mvc.i.Executer;

import weaver.general.KtreeHelp;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

public class E8BP_title {

	@SuppressWarnings({ "unused", "deprecation", "rawtypes" })
	public static void tt(String titlename, 
			User user, HttpServletRequest request,
			HttpServletResponse response, ServletContext application,
			Class<? extends Executer> ecpClass, 
			PageContext pageContext) throws Exception {
		
		javax.servlet.http.HttpSession session = request.getSession(true);
		PrintWriter out = response.getWriter();
		response.setContentType("text/html");
		response.setCharacterEncoding("UTF-8");
		request.setCharacterEncoding("UTF-8");
		

		out.write(_jsp_string0, 0, _jsp_string0.length);
		weaver.conn.RecordSet RecordSetFavourite;
		RecordSetFavourite = (weaver.conn.RecordSet) pageContext
				.getAttribute("RecordSetFavourite");
		if (RecordSetFavourite == null) {
			RecordSetFavourite = new weaver.conn.RecordSet();
			pageContext.setAttribute("RecordSetFavourite",
					RecordSetFavourite);
		}
		out.write(_jsp_string1, 0, _jsp_string1.length);

		String gopage = "";
		String hostname = request.getServerName();
		String uri = request.getRequestURI();
		String querystring = "";
		titlename = Util.null2String(titlename);
		String ajaxs = "";
		for (Enumeration En = request.getParameterNames(); En
				.hasMoreElements();) {
			String tmpname = (String) En.nextElement();

			if (tmpname.equals("ajax")) {
				ajaxs = tmpname;
				continue;
			}
			// String
			// tmpvalue=Util.toScreen(request.getParameter(tmpname),user.getLanguage(),"0");
			// querystring+="^"+tmpname+"="+tmpvalue;
			String[] paramValues = request.getParameterValues(tmpname); // \u4fee\u590dbug\uff0c\u6536\u85cf\u7684\u62a5\u8868\uff0c\u5217\u4e0d\u80fd\u5168\u90e8\u663e\u793a\u7684\u95ee\u9898\uff0cmodify
																		// by
																		// fmj
																		// 2015-03-013
			if (paramValues.length > 0) {
				for (int __kk = 0; __kk < paramValues.length; __kk++) {
					querystring += "^"
							+ tmpname
							+ "="
							+ Util.toScreen(paramValues[__kk],
									user.getLanguage(), "0");
				}
			}
		}
		if (!querystring.equals(""))
			querystring = querystring.substring(1);
		String pagename = titlename;

		session.setAttribute("fav_pagename", pagename);
		session.setAttribute("fav_uri", uri);
		session.setAttribute("fav_querystring", querystring);
		int addFavSuccess = Util.getIntValue(session
				.getAttribute("fav_addfavsuccess") + "");
		session.setAttribute("fav_addfavsuccess", "");
		pagename = URLEncoder.encode(pagename);

		// is workflow page
		boolean isWfFomPage = false;
		String strUrl = request.getRequestURL().toString();

		if (strUrl.indexOf("AddRequest.jsp") != -1
				|| strUrl.indexOf("ManageRequestNoForm.jsp") != -1
				|| strUrl.indexOf("ManageRequestNoFormMode.jsp") != -1
				|| strUrl.indexOf("ManageRequestNoFormBill.jsp") != -1
				|| strUrl.indexOf("ViewRequest.jsp") != -1) {
			isWfFomPage = true;
		}
		String isEnableExtranetHelp = KtreeHelp.isEnableExtranetHelp;

		out.write(_jsp_string2, 0, _jsp_string2.length);
		out.print((isEnableExtranetHelp));
		out.write(_jsp_string3, 0, _jsp_string3.length);
		out.print((KtreeHelp.extranetUrl));
		out.write(_jsp_string4, 0, _jsp_string4.length);
		out.print((URLEncoder.encode(uri)));
		out.write(_jsp_string5, 0, _jsp_string5.length);
		out.print((URLEncoder.encode(querystring)));
		out.write(_jsp_string6, 0, _jsp_string6.length);
		out.print((SystemEnv.getHtmlLabelName(2081, user.getLanguage())));
		out.write(_jsp_string7, 0, _jsp_string7.length);
	
	}

	private final static char[] _jsp_string7;
	private final static char[] _jsp_string2;
	private final static char[] _jsp_string0;
	private final static char[] _jsp_string5;
	private final static char[] _jsp_string3;
	private final static char[] _jsp_string6;
	private final static char[] _jsp_string4;
	private final static char[] _jsp_string1;
	static {
		_jsp_string7 = "\";\r\n	dialog.Width = 550 ;\r\n	dialog.Height = 600;\r\n	dialog.Drag = true;\r\n	dialog.show();\r\n}\r\n</script>"
				.toCharArray();
		_jsp_string2 = "\r\n\r\n<!-- bpf start 2013-10-23  -->	\r\n		\r\n		<style type=\"text/css\">\r\n			.popDiv{\r\n				float:right;\r\n				position:absolute;\r\n				top:0px;\r\n				right:0px;\r\n				display:none;\r\n				border:#D8D8D8 1px solid;\r\n			}\r\n			.shadowDiv{\r\n				position:absolute;\r\n				float:left;\r\n				top:0px;\r\n				right:0px;\r\n				width:11px;\r\n				height:7px;\r\n				z-index:3;\r\n				display:none;\r\n				background-image:url(/images/ecology8/angle_wev8.png);\r\n				background-repeat:no-repeat;\r\n			}\r\n		</style>\r\n		\r\n		<div class=\"shadowDiv\" id=\"shadowBorderDiv\"></div>\r\n\r\n\r\n\r\n\r\n<script language=javascript>\r\n\r\nfunction setBorder(){\r\n	var a = jQuery(\"span.selectedTitle\");\r\n	var div = jQuery(\"#shadowBorderDiv\");\r\n	//div.show();\r\n	var _top = a.offset().top+a.height();\r\n	var left = a.offset().left;\r\n	//div.width(a.width());\r\n	var width = a.width()+parseInt(a.css(\"padding-left\").replace(\"px\",\"\"))+parseInt(a.css(\"padding-right\").replace(\"px\",\"\"));\r\n	if(a.offset().top==0){\r\n		div.css(\"top\",_top-5);\r\n		div.css(\"left\",left+(width/2)-7);\r\n	}else{\r\n		div.each(function(){jQuery.dequeue(this,'fx');}).animate({top:_top-1,left:left-1}, 1500);\r\n	}\r\n}\r\n\r\njQuery(document).ready(function(){\r\n	window.setTimeout(function(){\r\n		try{\r\n			try{\r\n				preDo();\r\n			}catch(e){}\r\n			//setBorder();\r\n			try{\r\n				afterDo();\r\n			}catch(e){}\r\n		}catch(e){jQuery(\"#shadowBorderDiv\").hide();}\r\n	},10);\r\n	\r\n	jQuery(window).scroll(\r\n		function(){\r\n			try{\r\n				//setBorder();\r\n			}catch(e){}\r\n		}\r\n	);\r\n	\r\n	jQuery(\"#hoverBtnSpan\").bind(\"click\",function(e){\r\n		try{\r\n			//jQuery(\"#shadowBorderDiv\").hide();\r\n			setBorder();\r\n		}catch(e){jQuery(\"#shadowBorderDiv\").hide();}\r\n	});\r\n	\r\n});\r\n\r\nfunction startMouseMove(){\r\n	var handle = null;\r\n	jQuery(document).bind(\"mousemove\",function(e){\r\n		var event = e || window.event;\r\n		var pageX = e.pageX;\r\n		var width = jQuery(document).width();\r\n		//console.log(jQuery(document).width()+\"::\"+e.pageX+\"::\"+handle);\r\n		if(Math.abs(pageX-width)<=50){\r\n	if(handle==null){\r\n		   handle=window.setTimeout(function(){\r\n			jQuery(\"#popDiv\").show(\"slow\");\r\n	},1000);\r\n	}\r\n		}else{\r\n		clearTimeout(handle);\r\n		handle=null;\r\n	}\r\n	});\r\n	jQuery(\"#popDiv\").hover(function(){},function(){\r\n		jQuery(\"#popDiv\").hide(\"slow\");\r\n	});\r\n}\r\n\r\n\r\nfunction showHelp(){\r\n    /*var pathKey = this.location.pathname;\r\n    //alert(pathKey);\r\n    if(pathKey!=\"\"){\r\n        pathKey = pathKey.substr(1);\r\n    }*/\r\n    var pathKey = \"\";\r\n	var __url = this.location.href;\r\n	try {\r\n		var __regexp = new RegExp(\"http://[^/]+\", \"gmi\");\r\n		__url = __url.replace(__regexp, '');\r\n	} catch (e) {}\r\n	pathKey = encodeURIComponent(__url);\r\n    var operationPage = \"http://help.e-cology.com.cn/help/RemoteHelp.jsp\";\r\n    var screenWidth = window.screen.width*1;\r\n    var screenHeight = window.screen.height*1;\r\n\r\n    var isEnableExtranetHelp = "
				.toCharArray();
		_jsp_string0 = "\r\n\r\n\r\n\r\n\r\n\r\n\r\n".toCharArray();
		_jsp_string5 = "\";\r\n	var fav_querystring = \"".toCharArray();
		_jsp_string3 = ";\r\n    if(isEnableExtranetHelp==1){\r\n    	//operationPage = \"http://e-cology.com.cn/formmode/apps/ktree/ktreeHelp.jsp\";\r\n    	operationPage = '"
				.toCharArray();
		_jsp_string6 = "\";\r\n	\r\n	try\r\n	{\r\n			var e8tabcontainer = jQuery(\"div[_e8tabcontainer='true']\",parent.document);\r\n			if(e8tabcontainer.length > 0) \r\n			{\r\n				fav_uri = escape(parent.window.location.pathname);\r\n				fav_querystring = escape(parent.window.location.search);\r\n				navName = e8tabcontainer.find(\"#objName\").text();\r\n			}else{\r\n				navName = jQuery(\"#objName\").text();\r\n			}\r\n			//alert(fav_uri+\"  \"+fav_querystring)\r\n	}\r\n	catch(e)\r\n	{\r\n		\r\n	}\r\n	if(BacoTitle)\r\n	{\r\n		pagename = BacoTitle.text();\r\n	}\r\n	if(!pagename){\r\n		pagename = navName;\r\n	}\r\n	pagename = escape(pagename); \r\n	//window.showModalDialog('/systeminfo/BrowserMain.jsp?url=/favourite/FavouriteBrowser.jsp&fav_pagename='+pagename+'&fav_uri='+fav_uri+'&fav_querystring='+fav_querystring+'&mouldID=doc');\r\n	//var dialogurl = '/systeminfo/BrowserMain.jsp?url=/favourite/FavouriteBrowser.jsp&fav_pagename='+pagename+'&fav_uri='+fav_uri+'&fav_querystring='+fav_querystring+'&mouldID=doc';\r\n	var dialogurl = '/systeminfo/BrowserMain.jsp?url=/favourite/FavouriteBrowser.jsp&fav_uri='+fav_uri+'&mouldID=doc';  //fav_pagename\u548cfav_querystring\u4e0d\u901a\u8fc7url\u4f20\u503c\uff0c\u800c\u901a\u8fc7session\u83b7\u53d6\uff0c\u907f\u514durl\u8fc7\u957f\u65f6\uff0c\u5bfc\u81f4\u95ee\u9898\r\n	var dialog = new window.top.Dialog();\r\n	dialog.currentWindow = window;\r\n	dialog.URL = dialogurl;\r\n	dialog.Title = \""
				.toCharArray();
		_jsp_string4 = "';\r\n    }\r\n    window.open(operationPage+\"?pathKey=\"+pathKey,\"_blank\",\"top=0,left=\"+(screenWidth-800)/2+\",height=\"+(screenHeight-90)+\",width=1000,status=no,scrollbars=yes,toolbar=yes,menubar=no,location=no\");\r\n}\r\nfunction openFavouriteBrowser()\r\n{  \r\n	\r\n	var BacoTitle = jQuery(\"#BacoTitle\");\r\n	var pagename = \"\";\r\n	var navName = \"\";\r\n	var fav_uri = \""
				.toCharArray();
		_jsp_string1 = "\r\n\r\n".toCharArray();
	}
}
